import type { TableData } from '@arco-design/web-vue/es/table/interface';
import http from '@/utils/http'

/**
 * 查询请求体
 */
export interface QueryRequest {
  name?: string;
}

export interface PageQueryRequest extends QueryRequest, PageQuery {}

/**
 * 菜单查询响应
 */
export interface QueryResponse {
  id: number;
  pid: number;
  title: string;
  permission: string;
  type: number;
  sort: number;
  visible: number;
  status: number;
  cache: number;
  newWindow: number;
  icon: string;
  path: string;
  component: string;
  hide?: number;
  target?: number;
  children: Array<QueryResponse>;
}

/**
 * 菜单创建请求
 */
export interface CreateRequest {
  pid?: number;
  title?: string;
  permission?: string;
  type?: number;
  sort?: number;
  visible?: number;
  target?: number;
  icon?: string;
  path?: string;
  component?: string;
}
/**
 * 菜单更新请求
 */
export interface UpdateRequest extends CreateRequest {
  id?: number;
  status?: number;
}

/**
 * 菜单显示请求
 */
export interface UpdateHideRequest {
  id: number;
  hide: number;
}
/**
 * 查询列表
 */
export function getList(params: QueryRequest) {
  return http.get<QueryResponse[]>('/admin/menu/index', params);
}
/**
 * 修改状态
 */
export function updateRowStatus(request: UpdateRequest) {
  return http.post('/admin/menu/status', request);
}
/**
 * 修改隐藏
 */
export function updateRowHide(request: UpdateHideRequest) {
  return http.post('/admin/menu/hide', request);
}

/**
 * 通过 id 删除数据
 */
export function deleteRows(id: number) {
  return http.post('/admin/menu/delete', { id });
}

/**
 * 通过 id 新增更新数据
 */
export function updateRows(request: UpdateRequest) {
  return http.put('/admin/menu/edit', request);
}

export function getMenuList() {
  return http.put('/admin/index/getMenuList');
}
